package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dao.ComplaintadviceDao;
import com.pojo.Complaintadvice;
import com.service.ComplaintadviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComplaintadviceServiceImpl implements ComplaintadviceService {
    //注入ComplaintadviceDao
    @Autowired
    private ComplaintadviceDao complaintadviceDao;

    @Override
    public List<Complaintadvice> findByUid(Integer uid) {
        //首先构造QueryWrapper来进行条件的添加
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("u_id",uid);//相当于where id=1
        return complaintadviceDao.selectList(wrapper);
    }


    //添加
    @Override
    public boolean add(Complaintadvice complaintadvice) {
        return complaintadviceDao.insert(complaintadvice)>0 ? true : false;
    }
    //删除
    @Override
    public boolean delete(Integer id) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("id",id);//相当于where id=1
        return complaintadviceDao.delete(wrapper)>0 ? true : false;
    }
}
